﻿using UnityEngine.Playables;
using FrameOperateSync;

namespace Pvp.Timeline
{
    /// <summary>
    /// 辅助设置资源组
    /// </summary>
    [UnityEngine.RequireComponent(typeof(SkillPlayDirector))]
    public class SkillPlayDirectorAssist : UnityEngine.MonoBehaviour
    {
        public PlayableAsset[] assets;
        public bool modifySkillUpdaterFlag = false;
        public bool modifySkillPlayFlag = false;
        public int indexPlay = 0;

        private void Start()
        {
            var skillPlayDirector = GetComponent<SkillPlayDirector>();
            foreach (var ass in assets)
            {
                skillPlayDirector.AddAssetFormTrail(ass);
            }
        }

# if UNITY_EDITOR
        private void Update()
        {
            if (modifySkillUpdaterFlag)
            {
                SkillPlayDirector.UpdateFrame(0, UnityEngine.Time.deltaTime);
            }

            if (modifySkillPlayFlag)
            {
                modifySkillPlayFlag = false;
                GetComponent<SkillPlayDirector>().PlayAt((uint) indexPlay);
            }
        }
#endif
    }
}

